package com.fmdrama.test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

import com.fmdrama.util.GZIPUtil;

public class Home {
	
	public static void main(String[] args) {
		HttpClient client = new HttpClient();
		PostMethod getMethod = null;
		try{
			getMethod = new PostMethod("http://www.koreayh.com/");
			client.executeMethod(getMethod);
			String result = getMethod.getResponseBodyAsString();
//			parse(result);
			System.out.println(result);
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			getMethod.releaseConnection();
		}
	}
	
	public static void parse(String source){
		Pattern pattern = Pattern.compile("<a title=\"(.*?)\" href=\"(.*?)\">(.*?)</a>");
		Pattern p = Pattern.compile("<div class=\"index_movie_list_content\">([\\s\\S]*?)</div>");
		Matcher m = p.matcher(source);
		while(m.find()){
			String sub = m.group(0);
			Matcher matcher = pattern.matcher(sub);
			while(matcher.find()){
				System.out.println("标题：" +  matcher.group(1) + ", 地址：" +  matcher.group(2));
			}
		}
	}
	
}
